home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 37 / IOPROG_37.ISO / SOFT / Multilizer.exe / disk1 / data1.cab / data1 / [Group9]VCL Source Standard / IvConMod.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-12  |  5.5 KB  |  211 lines

  1. { This translator module component translates the TOutline, TStringGrid,
  2.   TListView, TTreeView and TStatusBar components. }
  3.  
  4. unit IvConMod;
  5.  
  6. {$I IVMULTI.INC}
  7.  
  8. interface
  9.  
  10. uses
  11.   Classes, Controls, IvMulti, IvDictio;
  12.  
  13. type
  14.   TIvControlModule = class(TIvModule)
  15.   public
  16.     function TranslateComponent(
  17.       translator: TIvTranslator;
  18.       component: TComponent): Boolean; override;
  19.  
  20.     function FlipControl(
  21.       translator: TIvTranslator;
  22.       control: TControl;
  23.       state: TIvBidirectionalState): Boolean; override;
  24.  
  25.     function ChangeComponentReadingOrder(
  26.       translator: TIvTranslator;
  27.       component: TComponent): Boolean; override;
  28.   end;
  29.  
  30. implementation
  31.  
  32. uses
  33. {$IFDEF WIN32}
  34.   ComCtrls,
  35. {$ENDIF}
  36.   Grids, Outline;
  37.  
  38. function TIvControlModule.TranslateComponent(
  39.   translator: TIvTranslator;
  40.   component: TComponent): Boolean;
  41. var
  42.   i, j, x, y: Integer;
  43.   stringGrid: TStringGrid;
  44.   outline: TOutline;
  45. {$IFDEF WIN32}
  46.   listView: TListView;
  47.   listItem: TListItem;
  48.   threeView: TTreeView;
  49. {$ENDIF}
  50. begin
  51.   if (component is TStringGrid) then
  52.   begin
  53.     Result := True;
  54.     if translator.Targets.IsPropertyInTargets(component.ClassName, 'Cells') then
  55.     begin
  56.       stringGrid := component as TStringGrid;
  57.  
  58.       { Translates the fixed columns }
  59.  
  60.       for x := 0 to stringGrid.FixedCols - 1 do
  61.         for y := 0 to stringGrid.RowCount - 1 do
  62.         begin
  63.           if ivtsPreScanning in translator.State then
  64.             translator.AddTranslation(
  65.               stringGrid,
  66.               component.Name,
  67.               'Cells',
  68.               stringGrid.Cells[x, y])
  69.           else
  70.             stringGrid.Cells[x, y] := translator.DoTranslateContextString(
  71.               stringGrid,
  72.               component.Name,
  73.               'Cells',
  74.               stringGrid.Cells[x, y]);
  75.         end;
  76.  
  77.       { Translates the fixed rows }
  78.  
  79.       for y := 0 to stringGrid.FixedRows - 1 do
  80.         for x := stringGrid.FixedCols to stringGrid.ColCount - 1 do
  81.         begin
  82.           if ivtsPreScanning in translator.State then
  83.             translator.AddTranslation(
  84.               stringGrid,
  85.               component.Name,
  86.               'Cells',
  87.               stringGrid.Cells[x, y])
  88.           else
  89.             stringGrid.Cells[x, y] := translator.DoTranslateContextString(
  90.               stringGrid,
  91.               component.Name,
  92.               'Cells',
  93.               stringGrid.Cells[x, y]);
  94.         end;
  95.     end;
  96.   end
  97.   else if (component is TOutline) then
  98.   begin
  99.     { The item range is from 1 to ItemCount }
  100.  
  101.     Result := True;
  102.     if translator.Targets.IsPropertyInTargets(component.ClassName, 'Lines') then
  103.     begin
  104.       outline := component as TOutline;
  105.       outline.BeginUpdate;
  106.       for i := 1 to outline.ItemCount do
  107.       begin
  108.         if ivtsPreScanning in translator.State then
  109.           translator.AddTranslation(
  110.             outline,
  111.             component.Name,
  112.             'Lines',
  113.             outline.Items[i].Text)
  114.         else
  115.           outline.Items[i].Text := translator.DoTranslateContextString(
  116.             outline,
  117.             component.Name,
  118.             'Lines',
  119.             outline.Items[i].Text);
  120.       end;
  121.       outline.EndUpdate;
  122.     end;
  123.   end
  124. {$IFDEF WIN32}
  125.   else if (component is TListView) then
  126.   begin
  127.     Result := True;
  128.     if translator.Targets.IsPropertyInTargets(component.ClassName, 'Items') then
  129.     begin
  130.       listView := component as TListView;
  131.       for i := 0 to listView.Items.Count - 1 do
  132.       begin
  133.         listItem := listView.Items[i];
  134.         if ivtsPreScanning in translator.State then
  135.         begin
  136.           translator.AddTranslation(
  137.             listItem,
  138.             component.Name,
  139.             'Caption',
  140.             listItem.Caption);
  141.           for j := 0 to listItem.SubItems.Count - 1 do
  142.             translator.AddTranslation(
  143.               listItem,
  144.               component.Name,
  145.               'Items',
  146.               listItem.SubItems[i]);
  147.         end
  148.         else
  149.         begin
  150.           listItem.Caption := translator.DoTranslateContextString(
  151.             listItem,
  152.             component.Name,
  153.             'Caption',
  154.             listItem.Caption);
  155.           translator.DoTranslateStrings(
  156.             listItem,
  157.             component.Name,
  158.             'Items',
  159.             listItem.SubItems);
  160.         end;
  161.       end;
  162.       listView.Repaint;
  163.     end;
  164.   end
  165.   else if (component is TTreeView) then
  166.   begin
  167.     Result := True;
  168.     if translator.Targets.IsPropertyInTargets(component.ClassName, 'Items') then
  169.     begin
  170.       threeView := component as TTreeView;
  171.       for i := 0 to threeView.Items.Count - 1 do
  172.       begin
  173.         if ivtsPreScanning in translator.State then
  174.           translator.AddTranslation(
  175.             threeView,
  176.             component.Name,
  177.             'Items',
  178.             threeView.Items[i].Text)
  179.         else
  180.           threeView.Items[i].Text := translator.DoTranslateContextString(
  181.             threeView,
  182.             component.Name,
  183.             'Items',
  184.             threeView.Items[i].Text);
  185.       end;
  186.     end;
  187.   end
  188. {$ENDIF}
  189.   else
  190.     Result := False;
  191. end;
  192.  
  193. function TIvControlModule.FlipControl(
  194.   translator: TIvTranslator;
  195.   control: TControl;
  196.   state: TIvBidirectionalState): Boolean;
  197. begin
  198.     Result := False;
  199. end;
  200.  
  201. function TIvControlModule.ChangeComponentReadingOrder(
  202.   translator: TIvTranslator;
  203.   component: TComponent): Boolean;
  204. begin
  205.     Result := False;
  206. end;
  207.  
  208. begin
  209.   Modules.Add(TIvControlModule.Create(nil));
  210. end.
  211.